<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!--360浏览器优先以webkit内核解析-->
    <title>个人资料</title>
    <link rel="shortcut icon" href="assets/manager/favicon.ico"> 
    <link href="assets/manager/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="assets/manager/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="assets/manager/css/animate.css" rel="stylesheet">
    <link href="assets/manager/css/style.css?v=4.1.0" rel="stylesheet">
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content">
        <div><h2 class="crumbs">个人资料</h2></div>
        <div class="row">
            <div class="col-sm-6">
                <div class="ibox float-e-margins p10">
                    <div class="form-group">
                       	 性别：
                        <label class="radio-inline"> 
						<input type="radio" value="男" id="sexM" name="sex">男</label> 
						<label class="radio-inline">
						<input type="radio" value="女" id="sexW" name="sex">女</label>
                    </div>
                    <div class="form-group" id="box">
                       	 出生日期：
                        <select id="year">
                        </select>
                        	年
                        <select id="month">
                        </select>
                        	月
                        <select id="day">
                        </select>
                        	日
                    </div>
                    <div class="form-group">
                        	手机号：
                        <input type="text" id="phone" name="phone" placeholder="手机号">
                    </div>
                    <div class="form-group">
                        Email：
                        <input type="text" id="email" name="email" placeholder="Email">
                    </div>
                    <div class="form-group">
                        	关于你自己：
                        <textarea id="aboutMe" style="width: 100%;height: 70px;" placeholder="关于我"></textarea>
                    </div>
                    <button id="save" class="btn btn-primary" type="submit">保存内容</button>
                    <button id="close" class="btn btn-white" type="submit">取消</button>
                </div>
            </div>
        </div>
    </div>
    <!-- 全局js -->
    <script src="assets/manager/js/jquery.min.js?v=2.1.4"></script>
    <script src="assets/manager/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="assets/manager/js/plugins/layer/layer.min.js"></script>
    <!-- Flot -->
    <script src="assets/manager/js/plugins/flot/jquery.flot.js"></script>
    <script src="assets/manager/js/plugins/flot/jquery.flot.tooltip.min.js"></script>
    <script src="assets/manager/js/plugins/flot/jquery.flot.resize.js"></script>
    <script src="assets/manager/js/plugins/flot/jquery.flot.pie.js"></script>
    <!-- 自定义js -->
    <script src="assets/manager/js/content.js"></script>
    <script src="assets/manager/js/dateSelect.js"></script>
    <!--flotdemo-->
    <script type="text/javascript">
	    $.get("mgindexgetuser",function(data){
	    	var $mInput = $(".form-group input[type='radio']").eq(0);
	    	var $wInput = $(".form-group input[type='radio']").eq(1);
	    	
	    	
	    	$("#phone").val(data.phone);
	    	$("#email").val(data.email);
			$("#aboutMe").val(data.aboutMe);
			if($mInput.val() == data.sex){
	    		$mInput.prop("checked",true);
	    	}else{
	    		$wInput.prop("checked",true);
	    	}
			if(data.bornD != null){
				var $dataArray = data.bornD.split("-");
				$("#year").val($dataArray[0]);
				$("#month").val($dataArray[1]);
				$("#day").val($dataArray[2]);
			}
		});
	    //修改userinfo
	    $("#save").click(function(){
    		register();
    	});
    	function register(){
    		$sex = $(".form-group input[type='radio']:checked").val();
    		$bornD = $("#year").val() + "-" + $("#month").val() + "-" + $("#day").val();
    		$dataObject={
    				sex:$sex,
    				bornD:$bornD,
    				phone:$("#phone").val(),
    				email:$("#email").val(),
    				aboutMe:$("#aboutMe").val(),
    		}
    		
    		$.ajax({
				type:"post",
				url:"edituserinfo",
				dataType:"json",
				contentType:"application/json;charset=utf-8",
				data:JSON.stringify($dataObject),
				success:function(data){
					if(data.res == 1){
						alert("修改成功！");
					}else{
						alert(data.resMsg);
					}
				}
			})
    	};
    	//修改userinfo
    </script>
</body>
</html>